package com.boulderai.mcp.model.llm;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;

/**
 * 大模型工具定义模型
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class LlmTool {
    
    @JsonProperty("type")
    private String type; // "function"
    
    @JsonProperty("function")
    private LlmFunctionDefinition function;
    
    public LlmTool() {}
    
    public LlmTool(String type, LlmFunctionDefinition function) {
        this.type = type;
        this.function = function;
    }
    
    // 静态工厂方法
    public static LlmTool createFunction(String name, String description, JsonNode parameters) {
        LlmFunctionDefinition functionDef = new LlmFunctionDefinition(name, description, parameters);
        return new LlmTool("function", functionDef);
    }
    
    // Getters and Setters
    public String getType() {
        return type;
    }
    
    public void setType(String type) {
        this.type = type;
    }
    
    public LlmFunctionDefinition getFunction() {
        return function;
    }
    
    public void setFunction(LlmFunctionDefinition function) {
        this.function = function;
    }
    
    /**
     * 函数定义
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public static class LlmFunctionDefinition {
        
        @JsonProperty("name")
        private String name;
        
        @JsonProperty("description")
        private String description;
        
        @JsonProperty("parameters")
        private JsonNode parameters; // JSON Schema格式的参数定义
        
        public LlmFunctionDefinition() {}
        
        public LlmFunctionDefinition(String name, String description, JsonNode parameters) {
            this.name = name;
            this.description = description;
            this.parameters = parameters;
        }
        
        // Getters and Setters
        public String getName() {
            return name;
        }
        
        public void setName(String name) {
            this.name = name;
        }
        
        public String getDescription() {
            return description;
        }
        
        public void setDescription(String description) {
            this.description = description;
        }
        
        public JsonNode getParameters() {
            return parameters;
        }
        
        public void setParameters(JsonNode parameters) {
            this.parameters = parameters;
        }
    }
}